Drop non-existent classpath entries before parsing - #468
Conversation
The Kotlin 2.4 compiler embedded in rewrite-kotlin throws "diagnostic collector is not initialized" when KotlinCoreEnvironment encounters a classpath root that does not exist, so every Kotlin source in a project with an empty source set output directory failed to parse.
|
Raised in review: doesn't the test create the file that's now being filtered out? ( It doesn't. Two separate things are handed to
To confirm rather than argue it, I instrumented the predicate to log every entry it keeps and drops, and ran
One thing worth calling out explicitly: the dropped |
RewriteRunTest.kotlinSourceGradle9has been failing onmainsince the 2026-08-20 nightly, withrewriteRunreporting:Nothing changed in this repo;
rewrite-kotlinsnapshots moved tokotlin-compiler-embeddable2.4.10. WhenKotlinCoreEnvironmenthits a classpath root that doesn't exist it tries to report a warning, and on 2.4.10 that report throws because no diagnostics collector is configured — taking the whole file's parse down with it.A source set's
runtimeClasspathincludes its own output directories, and those don't exist when the corresponding compile task isNO-SOURCE(build/classes/java/mainandbuild/resources/mainin the test project). Filtering non-existent entries out of the classpath we hand to the parsers avoids the crash; they carried no type information anyway.Applied at both sites that build a classpath for
KotlinParser.:plugin:testpasses locally (58 tests, 0 failures).